
#ifndef AUDIO_ACC_2_AMR_RECORDER_H
#define AUDIO_ACC_2_AMR_RECORDER_H

#include <string>
#include "ohcamera/camera.h"
#include "ohcamera/camera_input.h"
#include "ohcamera/capture_session.h"
#include "ohcamera/photo_output.h"
#include "ohcamera/preview_output.h"
#include "ohcamera/video_output.h"
#include "ohcamera/camera_manager.h"

class AvRecorder final {
public:
    static AvRecorder &GetInstance();
    void PrepareRecorder(const std::string &previewId, const std::string &videoId);
    void StartRecorder();
    void StopRecorder();
    void ReleaseRecorder();
    
private:
    static void OnCameraInputError(const Camera_Input* cameraInput, Camera_ErrorCode errorCode);
    static void OnFocusStateChange(Camera_CaptureSession* session, Camera_FocusState focusState);
    static void CaptureSessionOnError(Camera_CaptureSession* session, Camera_ErrorCode errorCode);
    static void VideoOutputOnFrameStart(Camera_VideoOutput* videoOutput);
    static void VideoOutputOnFrameEnd(Camera_VideoOutput* videoOutput, int32_t frameCount);
    static void VideoOutputOnError(Camera_VideoOutput* videoOutput, Camera_ErrorCode errorCode);
    static void StatusCallback(Camera_Manager* cameraManager, Camera_StatusInfo* status);
    static CameraInput_Callbacks* GetCameraInputListener();
    static CaptureSession_Callbacks* GetCaptureSessionRegister();
    static VideoOutput_Callbacks* GetVideoOutputListener();
    static CameraManager_Callbacks* GetCameraManagerListener();
    Camera_ErrorCode GetSupportCameras();
    Camera_ErrorCode GetCamerasOutputCapability();
    void ConfigCapSession();
    void ConfigInput();

    Camera_VideoOutput* videoOutput_ = nullptr;
    Camera_CaptureSession* captureSession_ = nullptr;
    Camera_Input* cameraInput_ = nullptr;
    Camera_PreviewOutput* previewOutput_ = nullptr;
    Camera_Manager* cameraManager_ = nullptr;
    Camera_Device* cameras_ = nullptr;
    Camera_OutputCapability* cameraOutputCapability_ = nullptr;
    Camera_Profile* previewProfile_ = nullptr;
    Camera_Profile* photoProfile_ = nullptr;
    Camera_VideoProfile* videoProfile_ = nullptr;
    uint32_t size_ = 0;
    uint32_t cameraDeviceIndex_ = 0;
};

#endif //AUDIO_ACC_2_AMR_RECORDER_H
